import Taro from "@tarojs/taro";

export const getToken = (): string => {
  return (Taro.getStorageSync("token") as string) || "";
};

export const setToken = (token: string): void => {
  Taro.setStorageSync("token", token);
};

export const removeToken = (): void => {
  Taro.removeStorageSync("token");
};

export const getClinicId = (): string => {
  return (Taro.getStorageSync("clinicId") as string) || "";
};

export const setClinicId = (clinicId: string): void => {
  Taro.setStorageSync("clinicId", clinicId);
};

export const removeClinicId = (): void => {
  Taro.removeStorageSync("clinicId");
};

/**
 * 清空所有用户信息
 * 包括 token、clinicId 和本地存储的其他用户相关数据
 */
export const clearAllUserInfo = (): void => {
  // 清空认证信息
  removeToken();
  // 这个不需要清空，因为clinicId是动态获取的
  // removeClinicId();
};
